FieldServiceDatabase.TestGrid = Ext.extend(Ext.grid.GridPanel, {
    buildTbar: function(){
        var download_button = new Ext.Button({
            xtype: 'button',
            text: 'Download',
            iconCls: 'download-icon'
        });
		
		var report_button = new Ext.Button({
            xtype: 'button',
            text: 'Report',
            iconCls: 'report-icon'
        });
		 
        this.download_button = download_button;
		this.report_button = report_button;
        this.tbar = new Ext.Toolbar({
            items: [download_button, report_button]
        })
    },
    page_size: FieldServiceDatabase.PAGESIZE,
    
    loadMask: true,
    id: 'testgrid-panel',
    
    frame: false,
    //        width: 600,
    height: 600,
    autoScroll: true,
    //        collapsible: true,
    
    animCollapse: false,
    region: 'center',
    
    title: 'Testing List',
    

    listener: {
        viewready: function(g){
            g.getSelectionModel().selectFirstRow()
        }
    },
    
    
    viewConfig: {
        forceFit: true
    },
    
    
    initComponent: function(){
        // paging bar on the bottom
        var page_size = this.page_size;
        var store = this.store;
		this.buildTbar();
        this.bbar = new Ext.PagingToolbar({
            pageSize: page_size,
            store: store,
            displayInfo: true,
            displayMsg: 'Displaying topics {0} - {1} of {2}',
            emptyMsg: "No topics to display"
        }), Ext.apply(this, {});
        
        FieldServiceDatabase.TestGrid.superclass.initComponent.call(this, arguments);
        this.getStore().on('exception', function(dp, type, action, options, response){
            Ext.MessageBox.confirm('Error', 'Network Temporarily not available, do you want to try again?', function(btn, text){
                if (btn == 'yes') {
                    this.load({params: options.params})
                }
                else {
                    this.removeAll()
                }
            }, this);
        })
    }
});

Ext.reg('testgrid', FieldServiceDatabase.TestGrid);

